package cc.vicp.djx314.starfood.service.dishes.impls;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cc.vicp.djx314.starfood.service.dishes.DishesRankService;
import cc.vicp.djx314.starfood.dao.dish.DishMapper;
import cc.vicp.djx314.starfood.domain.dish.Dish;
import cc.vicp.djx314.starfood.domain.dish.DishesRankKind;

@Service
public class DishesRankServiceImpl implements DishesRankService {
	//~属性=====================================================================
	@Autowired
	private DishMapper dishMapper;

	//~方法=====================================================================
	@Override
	@Transactional(readOnly = true)
	public boolean getRankKindForIfExists(final Integer rankKindId) {
		Integer getRankKindId = dishMapper.getCacheRankKindForIfExists(rankKindId);
		boolean isRankKindExists = false;
		if (getRankKindId != null) {
			isRankKindExists = true;
		}
		return isRankKindExists;
	}

	@Override
	@Transactional(readOnly = true)
	public List<Dish> getDishesRankOfOneKind(Integer rankKindId) {
		int offset = 0;
		RowBounds rowBounds = new RowBounds(offset, DISHES_RANK_MAX_NUM);
		List<Dish> dishesRank = dishMapper.getCacheDishesRankOfOneKind(rankKindId, rowBounds);
		return dishesRank;
	}

	@Override
	@Transactional(readOnly = true)
	public List<DishesRankKind> getRankKinds() {
		int offset = 0;
		RowBounds rowBounds = new RowBounds(offset, DISHES_RANK_KIND_MAX_NUM);
		List<DishesRankKind> dishesRankKinds = dishMapper.getCacheRankKinds(rowBounds);
		return dishesRankKinds;
	}

	//~getter和setter=====================================================================
}
